package com.synthefact.daj.model.threaded;


public interface ScheduleIf {

    /**
     * Register main thread
     * <p>
     * 
     * @param t
     *            the main thread to be registered.
     */
    void main(Thread t);

    /**
     * Register node t to schedule. This method is to be called before the
     * scheduler is activated.
     * 
     * @param t
     *            the node to register.
     */
    void register(ThreadedNodeIf t);

    /**
     * Gets the number of nodes to schedule.
     * 
     * @return the number of nodes to schedule.
     */
    int getNumber();

    /**
     * Is the thread with the given id ready?
     * 
     * @return true if the thread is with the given id ready.
     */
    boolean isReady(int i);

    /**
     * Terminate current thread (never returns)
     */
    void terminate();

    /**
     * Exempt current thread from scheduling and schedule other threads.
     * 
     * @return the index of current thread
     */
    int sleep();

    /**
     * Interrupt scheduling
     */
    void interrupt();

    /**
     * Interrupt execution and wait until acknowledged
     */
    void interruptWait();

    /**
     * Continue execution after interruption
     */
    void cont();

    /**
     * Continue execution slowly after interruption
     */
    void walk();

    /**
     * Continue execution for one step
     */
    void step();

    /**
     * Bring thread numbered `index` back to scheduling
     */
    void awake(int index);

    /**
     * Terminate execution of all threads
     */
    void exit();

    /**
     * Give control to thread `i`, (-1) signals no thread
     */
    void schedule(int i);

    /**
     * Schedule next program for execution
     */
    void schedule();

    /**
     * Increase network time
     */
    void incTime();

    /**
     * Return index of next program for execution (-1, if none)
     */
    int nextProgram();

}